package com.example.mobifin_busticket.views.dialogs;

import com.example.mobifin_busticket.BusTicketManagaer;
import com.example.mobifin_busticket.R;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;

public class SendSmsDilaog extends Dialog implements
		android.view.View.OnClickListener {
	String strPhNo;
	Context mcontext;
	EditText etSms;
	Button btn_send_sms;
	String stremailid, stremailsub, stremailbody, strtag, strsms;
	String[] strSMSSplit;

	public SendSmsDilaog(Context context, String stremailid,
			String stremailsub, String stremailbody, String strtag,
			String strsms) {
		super(context);
		// TODO Auto-generated constructor stub
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.send_sms_dialog);
		etSms = (EditText) findViewById(R.id.etSms);
		btn_send_sms = (Button) findViewById(R.id.btn_send_sms);
		btn_send_sms.setOnClickListener(this);
		this.mcontext = context;
		this.stremailid = stremailid;
		this.stremailsub = stremailsub;
		this.stremailbody = stremailbody;
		this.strtag = strtag;
		this.strsms = strsms;
		strSMSSplit = strsms.split(";");
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		if (etSms.getText().toString().trim().length() == 0) {
			etSms.setError(mcontext.getResources().getString(
					R.string.pleasevalidmobno));
		} else if (etSms.getText().toString().trim().length() > 0
				&& etSms.getText().toString().trim().length() < 10) {
			etSms.setError(mcontext.getResources().getString(
					R.string.pleasevalidmobnoatleast));
		} else {

			dismiss();
			BusTicketManagaer busTicketManager = new BusTicketManagaer();
			busTicketManager.sendEmailOrSMS(mcontext, stremailid, stremailsub,
					stremailbody, strtag, etSms.getText().toString() + ";"
							+ strSMSSplit[1]);
		}
	}
}
